package com.itlaobing.dao.impl;

import com.itlaobing.dao.IAccountDao;
import com.itlaobing.model.Account;
import com.itlaobing.util.AccountRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @Classname AccountDaoImpl
 * @Description TODO()
 * @Date 2020/9/15 14:22
 * @Author by Administrator
 * @Version v1.0
 */
@Repository
public class AccountDaoImpl implements IAccountDao {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Override
    public Account findById(Integer id) {
        String sql = "select * from tb_account where id = ?";
        return jdbcTemplate.queryForObject(sql, new AccountRowMapper(), id);
    }

    @Override
    public void update(Account account) {
        String sql = "update tb_account set money = ? where id = ?";
        jdbcTemplate.update(sql, account.getMoney(), account.getId());
    }
}
